Implementing Lazy Functional Languages on Stock Hardware: The Spineless Tagless G-Machine
نویسنده
چکیده
The Spineless Tagless G-machine is an abstract machine designed to support nonstrict higher-order functional languages. This presentation of the machine falls into three parts. Firstly, we give a general discussion of the design issues involved in implementing non-strict functional languages. Next, we present the STG language, an austere but recognisably-functional language, which as well as a denotational meaning has a well-de ned operational semantics. The STG language is the \abstract machine code" for the Spineless Tagless G-machine. Lastly, we discuss the mapping of the STG language onto stock hardware. The success of an abstract machine model depends largely on how e cient this mapping can be made, though this topic is often relegated to a short section. Instead, we give a detailed discussion of the design issues and the choices we have made. Our principal target is the C language, treating the C compiler as a portable assembler. This paper is to appear in the Journal of Functional Programming. Changes in Version 2.0: large new section on comparing the STG machine with other designs (Section 3); pro ling material (Section 11); index. Changes in Version 2.1: proper statement of the initial state of the machine (Section 5.1); reformulation of CAF updates (Section 10.8); new format for state transition rules, separating the guards which govern the applicability of the rules (\such that") from the auxiliary de nitions (\where") | Section 5. Changes in Version 2.2: introduction of the term \lambda-form"; new subsection on lambda lifting (Section 4.5); discussion of copy-vs-share in Section 10.6; allow a variablebinding form of default alternative in algebraic case expressions. Changes in Version 2.3: more explicit discussion of the translation into the STG language (Section 4.1); some re-ordering of sub-sections in Section 4; an overview of the code generation process at the start of Section 9. Changes in Version 2.4: new-format pro ling in Section 11; new section on black holes, saying how to avoid space leaks without black-holing (Section 9.3.3). Changes in Version 2.5: appendix added giving gory details. Apart from the appendix, this is essentially the version published in the Journal of Functional Programming. Very minor changes to main paper: xed bug in Fig 5, and other typos. Previously entitled \The Spineless Tagless G-machine: a second attempt".
منابع مشابه
Compiling Lazy Functional Programs Based on the Spineless Tagless G-Machine for the Java Virtual Machine
A systematic method of compiling lazy functional programs based on the Spineless Tagless G-machine (STGM) is presented for the Java Virtual Machine (JVM). A new specification of the STGM, which consists of a compiler and a reduction machine, is presented; the compiler translates a program in the STG language, which is the source language for the STGM, into a program in an intermediate language ...
متن کاملPutting the Spine Back in the Spineless Tagless G-Machine: An Implementation of Resumable Black-Holes
Interrupt handling is a tricky business in lazy functional languages: we have to make sure that thunks that are being evaluated can be halted and later restarted if and when they are required. This is a particular problem for implementations which use black-holing. Black-Holing deliberately makes it impossible to revert such thunks to their original state to avoid a serious space leak. Interact...
متن کاملThe Non-stop Spineless Tagless G-machine Draft
We describe a technique for incorporating Baker's incremental garbage collection algorithm into the Spineless Tagless G-machine on stock hardware. This algorithm eliminates the stop/go execution associated with bulk copying collection algorithms, allowing the system to place an upper bound on the time taken to perform a store operation. The implementation is based on the manipulation of code-po...
متن کاملImplementing the Rewriting Computational Model of Escher
In this paper we discuss implementation issues concerned with a new abstract machine for executing functional logic programs. This machine supports a pure rewriting computational model in the style of the programming language Escher. It is based on a simpli ed version of the Spineless Tagless G-Machine which was developed for the implementation of higher-order, lazy, purely functional languages...
متن کاملProfiling Lazy Functional Programs
Prooling tools, which measure and display the dynamic space and time behaviour of programs, are essential for identifying execution bottlenecks. A variety of such tools exist for conventional languages, but almost none for non-strict functional languages. There is a good reason for this: lazy evaluation means that the program is executed in an order which is not immediately apparent from the so...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- J. Funct. Program.
دوره 2 شماره
صفحات -
تاریخ انتشار 1992